<?php

namespace App\Events\Train\TrainOrder\Refund;

use App\Models\Train\TrainOrderPassengers\TrainOrderPassenger;
use App\Models\Trip\TripOrderRefund\TripOrderRefund;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

/**
 * 车票申请退票 失败
 * 如果有need pay 需要退回
 */
class TicketReturnFailedEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public TrainOrderPassenger $passenger;
    public TripOrderRefund     $refund_info;
    public string              $failed_reason;

    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct(TrainOrderPassenger $passenger, TripOrderRefund $refund_info, string $failed_reason)
    {
        $this->passenger     = $passenger;
        $this->refund_info   = $refund_info;
        $this->failed_reason = $failed_reason;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
